<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类式组件</title>
    <style>
        header{
            height: 100px;
            background: #aef;
        }

        section{
            height: 400px;
            background: #aab;
        }

        footer{
            height: 100px;
            background: #fea;
        }
    </style>
</head>
<body>
    <div id="root"></div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        //类式组件必须要继承 React.Component
        class Head extends React.Component{
            //每一个类式组件都有一个 render 方法, 返回虚拟 DOM 对象
            render(){
                return <header>顶部</header>;
            }
        }

        class Main extends React.Component {
            render(){
                return <section>内容</section>;
            }
        }

        class Foot extends React.Component {
            render(){
                return <footer>尾部</footer>;
            }
        }

        //找与标签同名的类, 然后『实例化对象』, 调用 render 方法, 得到 『虚拟DOM对象』
        // let vDOM = <div>
        //         <Head></Head>
        //         <Main />
        //         <Foot />
        //     </div>;
        class App extends React.Component{
            render(){
                return <div>
                    <Head></Head>
                    <Main />
                    <Foot />
                </div>;
            }
        }

        ReactDOM.render(<App />, document.querySelector('#root'));
    </script>
</body>
</html>